# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - original OPTIMIZER export does not play nice with our system
#  - configure with --enable-lto=no
#  - 32-bit cflags addition to fix FTBFS with liburcu

# Maintainer: Tobias Powalowski <tpowa@archlinux.org>

pkgname=xfsprogs
pkgver=6.10.0
pkgrel=1
pkgdesc="XFS filesystem utilities"
arch=('x86_64')
license=('GPL-2.0-only' 'LGPL-2.1-only')
url="https://xfs.wiki.kernel.org"
depends=('sh' 'util-linux-libs' 'device-mapper' 'libedit' 'libinih' 'liburcu')
optdepends=('icu: for xfs_scrub'
            'python: for xfs_scrub_all script'
            'smtp-forwarder: for xfs_scrub_fail script')
makedepends=('git' 'icu')
source=("git+https://git.kernel.org/pub/scm/fs/xfs/xfsprogs-dev.git?signed#tag=v${pkgver}")
b2sums=('38e1a9b6b38672673b7b28cb2038c76a54d9726265c95acc2766c177169d8c661add3d0c2c42fbb5a69b57f58ac49d5883bfa41aab78d770d4788bd13d9cb861')
validpgpkeys=(
  '2B8185919E8D248981869DED20AE1692E13DDEE0' # Eric Sandeen <sandeen@sandeen.net>
  '4020459E58C1A52511F5399113F703E6C11CF6F0' # Carlos Maiolino <cem@kernel.org>
)

build() {
  cd ${pkgname}-dev
  make configure
  [[ $CARCH != "aarch64" ]] && CFLAGS+=" -DUATOMIC_NO_LINK_ERROR"
  # Package is honoring CFLAGS; No need to use OPTIMIZER anymore.
  # However, we have to provide an empty value to avoid default
  # flags.
  export OPTIMIZER=" "
  ./configure --prefix=/usr --sbindir=/usr/bin --libexecdir=/usr/lib \
              --with-systemd-unit-dir=/usr/lib/systemd/system \
              --localstatedir=/var --enable-editline --enable-lto=no
  make
}

package() {
  cd ${pkgname}-dev
  make PKG_USER=root PKG_GROUP=root DIST_ROOT="${pkgdir}" \
       PKG_ROOT_SBIN_DIR="/usr/bin" install install-dev
}
